package org.example.struct.array2;

import java.util.ArrayList;
import java.util.List;

/**
 * @author liyishan
 * @date 2024/7/30 09:22
 * @apiNote
 */

public class Test02961GetGoodIndices {
    public List<Integer> getGoodIndices(int[][] variables, int target) {
        List<Integer> result = new ArrayList<>();
        for(int i = 0;i<variables.length;i++){
            int[] v= variables[i];
            if(powMod(powMod(v[0],v[1],10),v[2],v[3]) == target){
                result.add(i);
            }
        }
        return result;
    }

    public int powMod(int x,int y,int mod){
        int res = 1;
        while(y >0){
            if(y%2 == 1){
                res = res * x % mod;
            }
            x = x * x % mod;
            y/=2;
        }
        return res;
    }
}
